package controller.filemanager;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

import model.filemanager.FileManager;



@SuppressWarnings("serial")
public class DeleteServlet extends HttpServlet {

    public void doGet(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, IOException {

    	String key = req.getParameter("key");
		UserService userService = UserServiceFactory.getUserService();
		User user = userService.getCurrentUser();
    	new FileManager(user.getEmail()).DeleteFile(key);
    	res.sendRedirect(req.getHeader("Referer"));
    }
}